/**
 * center
 */
jQuery.fn.center = function() {
	this.css("position", "absolute");
	top = ($(window).height() - this.height()) / 2 + $(window).scrollTop();
	if (top < 0)
		top = 0;
	this.css("top", top + "px");
	left = ($(window).width() - this.width()) / 2 + $(window).scrollLeft();
	if (left < 0)
		left = 0;
	this.css("left", left + "px");
	return this;
};

jQuery.dialogUpload = function(options) {
	var dialog_upload = $('#dialog_upload');
	if (dialog_upload.length == 0) {
		dialog_upload = $('<div></div>').attr('id', 'dialog_upload');

	}
	var iframe = $('<iframe></iframe>').attr('src', options['url']).css( {
		margin : '-40px 0 0 0',
		width : '400px',
		height : '300px',
		border : '1px solid'
	});

	iframe.load(function() {
		var body = $(this).contents().find('body');
		if (body.find('form').length == 0) {// has been uploaded.
				eval('var res =' + body.html());

				dialog_upload.dialog('destroy');

				if (options['callback']) {
					var callback = options['callback'];
					callback(res);
				}
			}
		});

	dialog_upload.html('').append(iframe).dialog( {
		width : 450
	});
};

function dialogUpload(options) {

	var dialog_upload = $('#dialog_upload');
	if (dialog_upload.length == 0) {
		dialog_upload = $('<div></div>').attr('id', 'dialog_upload');

	}
	dialog_upload.load(options['url']).dialog();
}

function getImgSize(imgSrc) {
	var newImg = new Image();
	newImg.src = imgSrc;
	var height = newImg.height;
	var width = newImg.width;
	return {width:width,height:height};
//	alert('The image size is ' + width + '*' + height);
}